// pages/detail/detail.js
import http from '../../api/index'
const {baseURL} = require("../../utils/request")
Page({


  /**
   * 页面的初始数据
   */
  data: {
    baseURL: baseURL,
    facilitiesList: [],
    serviceList:[],
    campsiteList: [],
    campId: '',
  },

  listCamp() {
    http.campDetail(this.data.campId).then(res => {
      if (res.code == 200) {
        // let facilitiesList = res.rows.filter(item=>{
        //   return item.state == "1"
        // })
        this.setData({
          facilitiesList: res.data
        })
        console.log(res)
      }
    })
  },

  listCampsite(campId) {
    http.listCampsite(campId).then(res => {
      if (res.code == 200) {
        // let facilitiesList = res.rows.filter(item=>{
        //   return item.state == "1"
        // })
        this.setData({
          campsiteList: res.data
        })
        console.log(res)
      }
    })
  },

  getFacilityC(campid){
    // let campid=event.currentTarget.dataset.id;
    http.serviceFacilitiesSingle(campid).then(res=>{
      if(res.code==200){
        let imageList = res.rows
        this.setData({
          serviceList:imageList
        })
        console.log(this.data.serviceList)
      }
    })
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      campId: options.campId
    })
    this.listCamp();
    this.listCampsite(options.campId)
    this.getFacilityC(options.campId)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})